//
//  AXFCouponVC.m
//  BEEQUICK
//
//  Created by admin on 19/11/2016.
//  Copyright © 2016 SevenGroup. All rights reserved.
//

#import "AXFCouponVC.h"
#import "AXFTripleBtnsCell.h"
#import "AXFCouponCell.h"
#import "AXFCreditsMallVC.h"
#import "AXFWhiteNavView.h"

@interface AXFCouponVC ()<UITableViewDelegate, UITableViewDataSource, AXFWhiteNavViewDelegate>

@property (strong, nonatomic) UITableView *tableView;

@end

@implementation AXFCouponVC
static NSString * const topCellID = @"topCell";
static NSString * const bottomCellID = @"bottomCell";

- (UITableView *)tableView {
	if (!_tableView) {
		_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, kSCREENWIDTH, 108)];
		_tableView.rowHeight = 54;
		
		[self.view addSubview:_tableView];
		
		_tableView.dataSource = self;
		_tableView.delegate = self;
		
		[_tableView registerClass:[AXFTripleBtnsCell class] forCellReuseIdentifier:topCellID];
		[_tableView registerClass:[AXFCouponCell class] forCellReuseIdentifier:bottomCellID];
	}
	return _tableView;
}

- (void)viewDidLoad {
	[super viewDidLoad];
	// Do any additional setup after loading the view.
	self.navigationController.navigationBar.translucent = NO;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
//    self.navigationController.navigationBar.hidden = NO;
	
}

- (void)setupUI {
    
    self.navigationItem.title = @"购物券";
    
//    self.navigationController.navigationBar.hidden = NO;
    
	self.view.backgroundColor = [UIColor cz_colorWithHex:0xefefef];
	
	UIImageView *couponImageView = [[UIImageView alloc] init];
	UILabel *infoLabel = [UILabel lr_labelWithText:@"你还没有券哦" fontSize:15 color:0xa4a4a4];
	UIButton *convertBtn = [[UIButton alloc] init];
	
	couponImageView.image = [UIImage imageNamed:@"v2_coupon_empty"];
	
	[convertBtn setTitle:@"兑换积分券" forState:UIControlStateNormal];
	[convertBtn setTitleColor:[UIColor cz_colorWithHex:0xa4a4a4] forState:UIControlStateNormal];
	[convertBtn addTarget:self action:@selector(convertBtnAction) forControlEvents:UIControlEventTouchUpInside];
	
	convertBtn.layer.borderColor = [[UIColor cz_colorWithHex:0xe8e8e8] CGColor];
	convertBtn.layer.borderWidth = 1.1f;
	convertBtn.layer.cornerRadius = 5;
	convertBtn.layer.masksToBounds = YES;
	
	[self.view addSubview:couponImageView];
	[self.view addSubview:infoLabel];
	[self.view addSubview:convertBtn];
	
	[couponImageView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerX.equalTo(self.view);
		make.top.equalTo(self.tableView.mas_bottom).offset(125);
	}];
	
	[infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerX.equalTo(couponImageView);
		make.top.equalTo(couponImageView.mas_bottom).offset(22);
	}];
	
	[convertBtn mas_makeConstraints:^(MASConstraintMaker *make) {
		make.centerX.equalTo(infoLabel);
		make.top.equalTo(infoLabel.mas_bottom).offset(36);
		make.width.equalTo(@144);
		make.height.equalTo(@29);
	}];
	
	AXFWhiteNavView *whiteNavView = [[AXFWhiteNavView alloc] init];
	
	[whiteNavView setTitleName:@"优惠券" andFunctionName:nil];
	
	whiteNavView.delegate = self;
	
	[self.view addSubview:whiteNavView];
	
	[whiteNavView mas_makeConstraints:^(MASConstraintMaker *make) {
		make.left.right.top.offset(0);
		make.height.mas_equalTo(kNAVBARH + 20);
	}];
}

- (void)backToViewController {
	[self.navigationController popViewControllerAnimated:YES];
}

- (void)convertBtnAction {
	[self.navigationController pushViewController:[[AXFCreditsMallVC alloc] init] animated:YES];
}

- (void)didReceiveMemoryWarning {
	[super didReceiveMemoryWarning];
	// Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
	return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	if (indexPath.row == 0) {
		AXFTripleBtnsCell *cell = [tableView dequeueReusableCellWithIdentifier:topCellID forIndexPath:indexPath];
		cell.selectionStyle = NO;
		return cell;
	}
	AXFCouponCell *cell = [tableView dequeueReusableCellWithIdentifier:bottomCellID forIndexPath:indexPath];
	cell.selectionStyle = NO;
	return cell;
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
